package org.example.demo3.common;

import org.example.demo3.info.Delete_Review_Response;
import org.example.demo3.info.Userinfo;
import org.example.demo3.mapper.Articlemapper;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@Component
public class Session_delete {
    @Resource
    private  Articlemapper articlemapper;
    public  boolean verify_review(HttpServletRequest request,int id){
        Userinfo userinfo=Session.getsession(request);
        Delete_Review_Response deleteReviewResponse=articlemapper.verify_review(id);
        if (userinfo.getId().equals(deleteReviewResponse.getUid())||userinfo.getUsername().equals(deleteReviewResponse.getReviewname())){
            return true;
        }else {
            return false;
        }
    }
    public  boolean verify_response(HttpServletRequest request, int id){
        Userinfo userinfo=Session.getsession(request);
        Delete_Review_Response deleteReviewResponse=articlemapper.verify_response(id);
        if (userinfo.getId().equals(deleteReviewResponse.getUid())||userinfo.getUsername().equals(deleteReviewResponse.getResponsename())){
            return true;
        }else {
            return false;
        }
    }
}
